<script setup lang="ts">
import Dialog from '@/components/Dialog.vue'
import type {  RowType, DialogConfigType  } from '@/components/dialogType'

const formData: RowType = reactive({
})
const dialogRef = ref<InstanceType<typeof Dialog>>()
const exposeOpenDialogViewFn = (dialogConfig: DialogConfigType ) => {
    dialogRef.value?.exposeOpenDialogCommonFn(dialogConfig)
	Object.assign(formData, dialogConfig.row)
}

// 暴露给父组件
defineExpose({
    exposeOpenDialogViewFn
})
</script>

<template>
	<Dialog ref="dialogRef">
		<el-form :model="formData" label-width="80px">
			<el-form-item label="实例ID:">
				<el-input :value="formData.id" readonly />
			</el-form-item>
	
			<el-form-item label="实例名称:">
				<el-input :value="formData.name" readonly />
			</el-form-item>
	
			<el-form-item label="版本:">
				<el-input :value="formData.version" readonly />
			</el-form-item>
	
			<el-form-item label="内部版本:">
				<el-input :value="formData.build_info" readonly />
			</el-form-item>
	
			<el-form-item label="部署类型:">
				<el-input :value="`${formData.deploy_type === 1
					?  '单机'
					: formData.deploy_type === 2
						? '温备'
						: '热备' }`" readonly />
			</el-form-item>
	
			<el-form-item label="主/备:">
				<el-input :value="formData.is_primary ? '主' : '备'" readonly />
			</el-form-item>
	
			<el-form-item label="监听端口:">
				<el-input :value="formData.listen_addr" readonly />
			</el-form-item>
	
			<el-form-item label="Nat地址:">
				<el-input :value="formData.nat_addr" readonly />
			</el-form-item>
	
			<el-form-item label="权重:">
				<el-input :value="formData.weight" readonly />
			</el-form-item>
	
			<el-form-item label="管理端口:">
				<el-input :value="formData.listen_addr_admin" readonly />
			</el-form-item>
	
			<el-form-item label="启动时间:">
				<el-input :value="formData.start_timeStamp" readonly />
			</el-form-item>
		</el-form>
	</Dialog>
</template>

<style lang="scss" scoped>
:deep(.el-form) {
	label.el-form-item__label {
		display: inline-block;
		text-indent: 0;
		text-align: right;
	}

	textarea {
		margin-bottom: .2rem;
		height: 2rem;
	}
}
</style>